package com.ccx.library.util;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;

/**
 * 加密
 */
public class Md5Util {

    private static final String SALT="ccx666";

    public static String Encryption(String context){
        return createDigest(context);
    }

    public static String createDigest(String context){
        return DigestUtils.md5DigestAsHex((SALT + SALT + context + SALT + SALT).getBytes(StandardCharsets.UTF_8));
    }

    public static Boolean encode(String before,String after){
        return Encryption(before).equals(after);
    }
}
